<form class="layui-form seller-form" action="">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this"><a href="{:url('tranShop')}">商户(总消费)</a></li>
            <li><a href="{:url('tranShopUser')}" >商户(用户量)</a></li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class="layui-inline">
                    <div class="layui-input-inline seller-inline-3">
                        <input type="text" name="shop_name" lay-verify="title" placeholder="Shop Name" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
<!--                <div class="layui-inline" style="padding-left: 5px;">-->
<!--                    <input type="text" name="datetime" id="datetime" placeholder="Start Time _ End Time" autocomplete="off" class="layui-input">-->
<!--                </div>-->
                <div class="layui-inline">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*"><i class="iconfont icon-chaxun"></i>Search</button>
                        <button class="layui-btn layui-btn-sm" lay-submit lay-filter="user_data_update">Update Data</button>
                    </div>

                </div>
                <div class="layui-inline" style="padding-left: 5px;font-size: 20px">
                    Refresh Time : <span id="up_time" style="color: #FF5722">{$time}</span>;&nbsp;&nbsp;&nbsp;&nbsp;
                    统计时区 :<span  style="color: #FF5722;padding-left: 30px;">'UTC-5'(北京时间减13小时)</span>
                </div>
            </div>
        </div>
    </div>
</form>

<div class="table-body">
    <table id="balanceTable" lay-filter="balanceTable"></table>
</div>
<script>
    layui.use(['form', 'table' ,'laydate'], function () {

        //时间插件
        layui.laydate.render({
            elem: '#datetime',
            range: '_',
            format: 'yyyy-MM-dd'
        });

        var tableIn = layui.table.render({
            elem: '#balanceTable',
            height: 'full-99',
            cellMinWidth: '80',
            totalRow: true,
            method: 'post',
            // toolbar: '#toolbar', //开启头部工具栏，并为其绑定左侧模板
            // defaultToolbar: ['exports'],
            url: "{:url('cards/tranShop')}",
            id: 'balanceTable',
            cols: [[
                { type: 'numbers'},
                { field: 'shop', title: 'Shop Name', width:400 ,totalRowText:'Total Amount:'},
                { field: 'amount', align: 'right', title: 'Amount' ,style:'color:#FF5722;font-weight:bold' , width:200, totalRow: true},
                { field: 'num', align: 'right', title: 'Num' , width:100, totalRow: true},
            ]],
            page: true,
            limit: 100,
            limits: [100,1000,5000,10000],
        });
        layui.form.on('submit(*)', function (data) {
            layui.table.reload('balanceTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        layui.form.on('submit(user_data_update)', function () {
            var loading =layer.load(1, {shade: [0.1,'#fff']});
            JsPost("{:url('tranShopUp')}",'', function(res){
                layer.close(loading);
                if(res.code >0){
                    $('#up_time').text(res.data.time);
                    layer.msg(res.msg, { time: 1500 , icon:1}, function () {
                        tableIn.reload({
                            page:{
                                curr :1
                            }
                        });
                    });
                }else{
                    layer.msg(res.msg , {time:1500 , icon:2});
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>